#ifndef CHATMESSAGEUI_H
#define CHATMESSAGEUI_H

#include <QWidget>
#include <QPaintEvent>
#include <QPainter>
#include <QPixmap>

class CChatMessage;
class ChatMessageUI;

class ChatMessgeUIPainter{
public:
    explicit ChatMessgeUIPainter(){ }
    virtual ~ChatMessgeUIPainter() { }

    virtual void PainterContexnt(QPainter& ) = 0;
    virtual QSize GetSize(void) const = 0;

protected:
};

class ChatMessageUIPainterDoctor : ChatMessgeUIPainter{
public:
    explicit ChatMessageUIPainterDoctor(){ }
    virtual ~ChatMessageUIPainterDoctor() { }

    virtual void Decorator(ChatMessgeUIPainter* pChatMessgeUIPainter ) {
        m_pChatMessgeUIPainter = pChatMessgeUIPainter;
    }
    virtual QSize GetSize(void) const {
        if (nullptr == m_pChatMessgeUIPainter){
            return QSize(0, 0);
        }

        return m_pChatMessgeUIPainter->GetSize();
    }

protected:
    ChatMessgeUIPainter* m_pChatMessgeUIPainter = nullptr;
};

class ChatMessageUI : public QWidget
{
public:
    ChatMessageUI(CChatMessage* pChatMessage, QWidget* parent = nullptr);

protected:
    virtual void paintEvent(QPaintEvent* e);

public:
   CChatMessage* GetMessage() const;

protected:
    void paintHeadImge(QPainter *painter);
    QPixmap Pixmap2Round(QPixmap& src, int radius);

private:
    CChatMessage* m_pChatMessage;
    QPixmap m_pHeadImage;
};

#endif // CHATMESSAGEUI_H
